//
//  CommenMacro.h
//  QLadder
//
//  Created by xiongguobing on 2019/8/12.
//  Copyright © 2019 qding. All rights reserved.
//

#ifndef CommenMacro_h
#define CommenMacro_h

#define KToken              @"token"
#define kUserAccount        @"userAccount"
#define kUserPassword       @"userPassword"
#define kPaymentDidPaySuccess @"kPaymentDidPaySuccess"

//网络请求单例
#define kNetworkUtil        [BaseNetworkUtil sharedInstance]
//拼接字符串
#define Append2Str(str1,str2) ([NSString stringWithFormat:@"%@%@",str1,str2])

//控制台打印不全
#ifdef DEBUG
#define NSLog(FORMAT, ...) fprintf(stderr, "%s:%d\t%s\n", [[[NSString stringWithUTF8String: __FILE__] lastPathComponent] UTF8String], __LINE__, [[NSString stringWithFormat: FORMAT, ## __VA_ARGS__] UTF8String]);
#else
#define NSLog(FORMAT, ...) nil
#endif

//判断是否是iPhoneX
#define KIsiPhoneX \
({BOOL isPhoneX = NO;\
if (@available(iOS 11.0, *)) {\
isPhoneX = [[UIApplication sharedApplication] delegate].window.safeAreaInsets.bottom > 0.0;\
}\
(isPhoneX);})

//路径相关
//获取沙盒 Document
#define kPathDocument [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]

//获取沙盒 Cache
#define kPathCache [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject]

//强弱引用
#define kWeakSelf(type)  __weak typeof(type) weak##type = type;
#define kStrongSelf(type) __strong typeof(type) type = weak##type;

// 提示文字
#define kShowWithString(str) [HUDUtil showStr:str];

//获取系统对象
#define kApplication        [UIApplication sharedApplication]
#define kAppWindow          [UIApplication sharedApplication].delegate.window
#define kAppDelegate        [AppDelegate shareAppDelegate]
#define kRootViewController [UIApplication sharedApplication].delegate.window.rootViewController
#define kUserDefaults       [NSUserDefaults standardUserDefaults]
#define kNotificationCenter [NSNotificationCenter defaultCenter]

//收起键盘
#define kDismissKeyboard    [kAppWindow endEditing:YES]

#define kScreenWidth [[UIScreen mainScreen] bounds].size.width
#define kScreenHeight [[UIScreen mainScreen] bounds].size.height

//基本颜色
#define ThemeColor kColorWithHex(0x549E93)//App主色 主要用于顶部 以及特殊文字和折线

#define ClearColor [UIColor clearColor]

#define WhiteColor [UIColor whiteColor]

#define BlackColor [UIColor blackColor]

#define GrayColor [UIColor grayColor]

#define GrayLightColor [UIColor lightGrayColor]

#define BlueColor [UIColor blueColor]

#define RedColor [UIColor redColor]

///颜色 a代表透明度
#define RGBA(r,g,b,a) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:a]
#define RGB(r,g,b) RGBA(r,g,b,1.0f)
#define kColorWithHexStr(color) [UIColor colorWithHexString:color]

//16进制颜色
#define kColorWithHex(rgbValue) \
[UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16)) / 255.0 \
green:((float)((rgbValue & 0xFF00) >> 8)) / 255.0 \
blue:((float)(rgbValue & 0xFF)) / 255.0 alpha:1.0]


//判断非空
#define ValidStr(f) (f!=nil && ![f isKindOfClass:[NSNull class]] && [f isKindOfClass:[NSString class]] && ![f isEqualToString:@""])
#define ValidDict(f) (f!=nil && [f isKindOfClass:[NSDictionary class]])
#define ValidArray(f) (f!=nil && [f isKindOfClass:[NSArray class]] && [f count]>0)

#endif /* CommenMacro_h */
